<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/6/22 0022
 * Time: 10:22
 */
namespace app\currency\controller;

use library\Controller;

use think\Console;

use think\Db;

/**
 * 保险控制器
 * Class Insurance
 * @package app\currency\controller
 */
class Insurance extends Controller
{
    /**
     * 指定数据表
     * @var string
     */
    protected $table = 'Insurance';

    /**
     * 保险列表管理
     * @menu true
     * @auth true
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     */
    public function index()
    {
        $this->title = '轮播图管理';
        $this->_query($this->table)->like('title')->where(['is_deleted'=>0])->order('create_at desc')->page();
    }

    /**
     * 添加保险
     * @auth true
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     * @throws \think\exception\PDOException
     */
    public function add()
    {
        $this->_form($this->table, 'form');
    }
    /**
     * 禁用
     * @auth true
     * @throws \think\Exception
     * @throws \think\exception\PDOException
     */

    public function forbid()

    {

        $this->_save($this->table, ['status' => '0']);

    }


    /**
     * 启用
     * @auth true
     * @throws \think\Exception
     * @throws \think\exception\PDOException
     */

    public function resume()

    {

        $this->_save($this->table, ['status' => '1']);

    }


    /**
     * 删除
     * @auth true
     * @throws \think\Exception
     * @throws \think\exception\PDOException
     */

    public function remove()

    {

        $this->_delete($this->table);

    }

}